// 实现一个基础input组件
import React from 'react'
import ReactDOM from 'react-dom'
import {HashRouter as Router, Route, Switch, withRouter} from 'react-router-dom'

const App = () => {
  return (
    <Router>
    <div>
        <Switch>
          <Route path='/home' render={(props) => {
            console.log(props)
            return <h1>Home</h1>
          }}></Route>
          <Route path='/list' component={List}></Route>
        </Switch>
    </div>
    </Router>
  )
}

const List = (props) => {
  console.log(props)
  return (
    <div>
       <h1>List</h1>
       <Hello/>
    </div>
   
  )
}

let Hello = (props) => {
  return <button onClick={() => {
    props.history.push('/home')
  }}>点我回到首页</button>
}

Hello = withRouter(Hello)
ReactDOM.render(<App/>, document.getElementById('root'))